import { v4 as uuidv4 } from 'uuid';
import { Seeder } from '../../umzug';

/**
 * 已认证但是未完成基本信息的用户
 * 即该用户的 complateFlag 为 0
 */
export const authenticatedButMissingBasicInformation = {
  id: 1,
  uuid: uuidv4(),
  tel: '15625547446',
  complate_flag: 0,
  created_at: new Date(),
  updated_at: new Date()
};

/**
 * 完成基本信息但并未答题的用户
 */
export const informationCompleteButNoAnswerUser = {
  id: 2,
  uuid: uuidv4(),
  tel: '15305165114',
  gender: 1,
  complate_flag: 1,
  marital_status: 1,
  children_situation: 1,
  age: 1,
  education: 1,
  work_unit: 'The revenue',
  affiliated: 'Industrial and commercial bureau',
  job_position: 'accounting',
  operating_post: 'The front desk',
  created_at: new Date(),
  updated_at: new Date()
};

/**
 * 正在答题的用户
 * 即该用户答题的数量大于 0 且小于 62
 */
export const answeringUser = {
  id: 3,
  uuid: uuidv4(),
  tel: '15974267798',
  gender: 2,
  complate_flag: 1,
  marital_status: 1,
  children_situation: 1,
  age: 1,
  education: 1,
  work_unit: 'The revenue',
  affiliated: 'Industrial and commercial bureau',
  job_position: 'accounting',
  operating_post: 'The front desk',
  created_at: new Date(),
  updated_at: new Date()
};

/**
 * 完成答题的用户
 * 即该用户的答题数量为 62
 */
export const anwserCompletedUser = {
  id: 4,
  uuid: uuidv4(),
  tel: '14305127885',
  gender: 1,
  complate_flag: 1,
  marital_status: 1,
  children_situation: 1,
  age: 1,
  education: 1,
  work_unit: 'The revenue',
  affiliated: 'Industrial and commercial bureau',
  job_position: 'accounting',
  operating_post: 'The front desk',
  created_at: new Date(),
  updated_at: new Date()
};

/**
 * 答题数目超出题目总数的用户
 * 即该用户的答题数量超过了 62
 */
export const beyondTotalNumberOfQuestionsUser = {
  id: 5,
  uuid: uuidv4(),
  tel: '13305362101',
  gender: 1,
  complate_flag: 1,
  marital_status: 0,
  children_situation: 1,
  age: 1,
  education: 1,
  work_unit: 'The revenue',
  affiliated: 'Industrial and commercial bureau',
  job_position: 'accounting',
  operating_post: 'The front desk',
  created_at: new Date(),
  updated_at: new Date()
};

export const seedUsers = [
  authenticatedButMissingBasicInformation,
  informationCompleteButNoAnswerUser,
  answeringUser,
  anwserCompletedUser,
  beyondTotalNumberOfQuestionsUser
];

export const up: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkInsert('users', seedUsers);
};

export const down: Seeder = async ({ context: sequelize }) => {
  await sequelize.getQueryInterface().bulkDelete('users',
    { id: seedUsers.map((u) => u.id) });
};
